# import requests
# import json
#
#
# def ollama_chat(prompt, assistant_message_id, model="gemma:7b"):
#     # 设置键的失效时间为60秒
#     url = 'http://127.0.0.1:11434/api/generate'
#     data = {
#         # "model": "gemma:7b",
#         "model": model,
#         "prompt": prompt
#     }
#     headers = {'Content-Type': 'application/json'}
#     response = requests.post(url, data=json.dumps(data), headers=headers, stream=True)
#     full_response = ""
#     for line in response.iter_lines():
#         if line:
#             res = json.loads(line.decode('utf-8'))
#             print(res.get('response', None))
#             full_response += res.get('response', None)
#             yield json.dumps({'text': res.get('response', None)}) + "&&##&&"
#
#
# def ollama_chat_all(prompt, assistant_message_id, model="gemma:7b"):
#     # 设置键的失效时间为60秒
#     url = 'http://127.0.0.1:11434/api/generate'
#     data = {
#         # "model": "gemma:7b",
#         "model": model,
#         "prompt": prompt
#     }
#     headers = {'Content-Type': 'application/json'}
#     response = requests.post(url, data=json.dumps(data), headers=headers, stream=True)
#     full_response = ""
#     for line in response.iter_lines():
#         if line:
#             res = json.loads(line.decode('utf-8'))
#             print(res.get('response', None))
#             full_response += res.get('response', None)
#     return full_response
#
#
# def fuzi_chat(model_suffix, user_text, assistant_message_id, history=None):
#     url = 'http://127.0.0.1:5002/fuzi/chat'
#     data = {
#         "model_suffix": model_suffix,
#         "user_text": user_text,
#         "assistant_message_id": assistant_message_id,
#         "history": history
#     }
#
#     headers = {'Content-Type': 'application/json'}
#     response = requests.post(url, data=json.dumps(data), headers=headers, stream=True)
#     for line in response.iter_lines():
#         if line:
#             # res = json.loads(line.decode('utf-8'))
#             print(line)
#             yield line
#
#
# def fuzi_stop(assistant_message_id):
#     url = 'http://10.206.60.14:5001/fuzi/stop'
#     data = {
#         "assistant_message_id": assistant_message_id
#     }
#
#     headers = {'Content-Type': 'application/json'}
#     response = requests.post(url, data=json.dumps(data), headers=headers, stream=True)
